package com.itheima.tlias84.config;


import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSBuilder;
import com.aliyun.oss.OSSClientBuilder;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 使用@Bean注解，自动装配，阿里云Oss对象，实现阿里云连接对象的复用
 */
@Configuration
public class LoadOssConfig {


    @Resource
    AliyunOssConfig ossConfig1;


    /**
     * 创建阿里云链接信息OssBean
     * @return
     */
    @Bean("ossBean1")
    public OSS createOss(){
        OSS build = new OSSClientBuilder().build(ossConfig1.getEndpoint(), ossConfig1.getAccessKeyId()
                , ossConfig1.getSecretAccessKey());
        return build;
    }
}
